<!--_meta 作为公共模版分离出去-->
<#include "include/_meta.html">
<!--/meta 作为公共模版分离出去-->

<title>添加保险记录- 车辆管理</title>
<meta name="keywords" content="汽车租赁">
<meta name="description" content="H-ui.admin v2.3，是一款由国人开发的轻量级扁平化网站后台模板，完全免费开源的网站后台管理系统模版，适合中小型CMS后台系统。">
</head>
<body>
<article class="page-container">
    <form class="form form-horizontal" id="form-car-add" >
    
    <div class="row cl">
        <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>车牌号：</label>
        <div class="formControls col-xs-8 col-sm-9">
            <input type="text" class="input-text" autocomplete="off" value="" placeholder="车牌号" id="carcode" name="carcode">
        </div>
    </div>
        
        <div class="row cl">
        <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>车牌颜色：</label>
        <div class="formControls col-xs-8 col-sm-9">
            <input type="text" class="input-text" autocomplete="off" value="" placeholder="车牌颜色" id="carcolor" name="carcolor">
        </div>
    </div>
            
        <div class="row cl">
        <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>购买日期：</label>
        <div class="formControls col-xs-8 col-sm-9">
            <input type="text"  class="input-text Wdate" onfocus="WdatePicker({skin:'whyGreen',startDate:'%y-%M-%d %H:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss'})" autocomplete="off" lder="还车时间" id="buydate" name="buydate">
        </div>
    </div>
            
        <div class="row cl">
        <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>发动机号：</label>
        <div class="formControls col-xs-8 col-sm-9">
            <input type="text" class="input-text" autocomplete="off" value="" placeholder="发动机号" id="enginenum" name="enginenum">
        </div>
    </div>
            
        <div class="row cl">
        <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>车架号：</label>
        <div class="formControls col-xs-8 col-sm-9">
            <input type="text" class="input-text" autocomplete="off" value="" placeholder="车架号" id="framenum" name="framenum">
        </div>
    </div>
            
        <div class="row cl">
        <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>车辆类型：</label>
        <div class="formControls col-xs-8 col-sm-9">
            <input type="text" class="input-text" autocomplete="off" value="" placeholder="车辆类型" id="cartype" name="cartype">
        </div>
    </div>
            
        <div class="row cl">
        <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>车辆品牌：</label>
        <div class="formControls col-xs-8 col-sm-9">
            <input type="text" class="input-text" autocomplete="off" value="" placeholder="车辆品牌" id="carbrand" name="carbrand">
        </div>
    </div>
            
        <div class="row cl">
        <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>品牌型号：</label>
        <div class="formControls col-xs-8 col-sm-9">
            <input type="text" class="input-text" autocomplete="off" value="" placeholder="品牌型号" id="carbrandtype" name="carbrandtype">
        </div>
    </div>
            
        <div class="row cl">
        <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>车辆图片：</label>
        <div class="formControls col-xs-8 col-sm-9">
            <input type="text" class="input-text" value="" placeholder="车辆图片"   id="picid" name="picid">            
        </div>
    </div>
     
		<div class="row cl">
        <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>添加图片：</label>
		<div id="uploader-demo" style="withed:150px;height:150px" >
    		<!--用来存放item-->
    		<div id="fileList" class="uploader-list"></div>
    		<div id="filePicker">选择图片</div>   		
		</div>
 </div>
    <div class="row cl">
        <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>自动手动：</label>
        <div class="formControls col-xs-8 col-sm-9">
            <input type="text" class="input-text" autocomplete="off" value="" placeholder="自动手动" id="isauto" name="isauto">
        </div>
    </div> 
        <div class="row cl">
        <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>排量大小：</label>
        <div class="formControls col-xs-8 col-sm-9">
            <input type="text" class="input-text" autocomplete="off" value="" placeholder="排量大小" id="enginesize" name="enginesize">
        </div>
    </div>
            
        <div class="row cl">
        <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>座位数量：</label>
        <div class="formControls col-xs-8 col-sm-9">
            <input type="text" class="input-text" autocomplete="off" value="" placeholder="座位数量" id="seatnum" name="seatnum">
        </div>
    </div>
            
        <div class="row cl">
        <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>外观类型：</label>
        <div class="formControls col-xs-8 col-sm-9">
            <input type="text" class="input-text" autocomplete="off" value="" placeholder="外观类型" id="facetype" name="facetype">
        </div>
    </div>
        
    <div class="row cl">
        <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>当前里程数字：</label>
        <div class="formControls col-xs-8 col-sm-9">
            <input type="text" class="input-text" autocomplete="off" value="" placeholder="当前里程数字" id="totalmile" name="totalmile">
        </div>
    </div>

    
    <div class="row cl">
        <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>下次保养时间：</label>
        <div class="formControls col-xs-8 col-sm-9">
            <input type="text"  class="input-text Wdate" onfocus="WdatePicker({skin:'whyGreen',startDate:'%y-%M-%d %H:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss'})"  autocomplete="off"  placeholder="下次保养时间" id="maintaintime" name="maintaintime">
        </div>
    </div>
        <div class="row cl">
        <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>下次保养里程：</label>
        <div class="formControls col-xs-8 col-sm-9">
            <input type="text" class="input-text" autocomplete="off" value="" placeholder="下次保养里程" id="maintainmile" name="maintainmile">
        </div>
    </div>
        


    <div class="row cl">
        <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>年检到期：</label>
        <div class="formControls col-xs-8 col-sm-9">
        <input type="text"  class="input-text Wdate" onfocus="WdatePicker({skin:'whyGreen',startDate:'%y-%M-%d %H:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss'})" autocomplete="off" lder="还车时间" id="yearcheck" name="yearcheck">
        </div>
    </div>          
    
    
    
    <div class="row cl">
        <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>保险到期：</label>
        <div class="formControls col-xs-8 col-sm-9">
            <input type="text"  class="input-text Wdate" onfocus="WdatePicker({skin:'whyGreen',startDate:'%y-%M-%d %H:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss'})" autocomplete="off" lder="还车时间" id="insurancetime" name="insurancetime">
        </div>
        
    </div>
        <div class="row cl">
        <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>提醒手机号：</label>
        <div class="formControls col-xs-8 col-sm-9">
            <input type="text" class="input-text" autocomplete="off" value="" placeholder="提醒手机号" id="phone" name="phone">
        </div>
        
    </div>
        <div class="row cl">
        <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>每日租金：</label>
        <div class="formControls col-xs-8 col-sm-9">
            <input type="text" class="input-text" autocomplete="off" value="" placeholder="每日租金" id="dayprice" name="dayprice">
        </div>
        
    </div>
        <div class="row cl">
        <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>所在区域城市：</label>
        <div class="formControls col-xs-8 col-sm-9">
             <select id="carcity">
            <option value=0>所在区域城市</option>
            <option value=1>郑州市</option>
            <option value=2>新乡市</option>
            <option value=3>洛阳市</option>
        </select>
        </div>
    </div>
        
                <div class="row cl">
        <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>所属租赁门店：</label>
        <div class="formControls col-xs-8 col-sm-9">
            <select id="deptname">
        	 <option value=0>所属租赁门店</option>
        	 <option value=0>所在区域城市</option>
            <option value=1>郑州市</option>
            <option value=2>新乡市</option>
            <option value=3>洛阳市</option>
             </select>
        </div>
    </div>
        <div class="row cl">
        <label class="form-label col-xs-4 col-sm-3">车辆信息介绍：</label>
        <div class="formControls col-xs-8 col-sm-9">
            <textarea id="carremark" name="carremark" cols="" rows="" class="textarea"  placeholder="说点什么...100个字符以内" dragonfly="true" onKeyUp="textarealength(this,100)"></textarea>
            <p class="textarea-numberbar"><em class="textarea-length">0</em>/100</p>
        </div>
    </div>

    <div class="row cl">
        <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
            <input class="btn btn-primary radius" type="button" value="&nbsp;&nbsp;提交&nbsp;&nbsp;" onclick="$('#form-car-add').submit()"/>
        </div>
    </div>
    </form>
</article>

<!--_footer 作为公共模版分离出去--> 
<#include "include/_footer.html">
<!--/_footer /作为公共模版分离出去--> 
<script type="text/javascript" src="lib/webuploader/0.1.5/webuploader.min.js"></script> 
<!--请在下方写此页面业务相关的脚本--> 
<script type="text/javascript">

function getCarid(){	
		$.ajax({
	            type: 'post', 				 
	            url: '/getCarsByIdcar',
	            data:{'carid':$("#carid").val()},
				success:function(data){ 
	 				if(data.flag == 'false'){
	 					alert("车牌号已存在！！");
	 					$("#carid").attr("value",'')
	 				}
	           }
		});
	}

$(function(){
var uploader = WebUploader.create({
auto: true,
swf: 'lib/webuploader/0.1.5/Uploader.swf',
server: '/uploadFile',
pick: '#filePicker',
fileVal:'uploadfile',
resize: false,
accept: {
title: 'Images',
extensions: 'gif,jpg,jpeg,bmp,png',
mimeTypes: 'image/*'          
}

});

// 当有文件添加进来的时候
uploader.on( 'fileQueued', function( file ) {
    var $li = $(
            '<div id="' + file.id + '" class="file-item thumbnail">' +
                '<img>' +
                '<div class="info">' + file.name+ '</div>' +
            '</div>'
            ),
        $img = $li.find('img');
    // $list为容器jQuery实例
   
    $("#uploader-demo").append($li );

    // 创建缩略图
    // 如果为非图片文件，可以不用调用此方法。
    // thumbnailWidth x thumbnailHeight 为 100 x 100
    uploader.makeThumb( file, function( error, src ) {
        if ( error ) {
            $img.replaceWith('<span>不能预览</span>');
           
            return;
        }
		 
        $img.attr( 'src', src );
    }, "100","100");
});





// 文件上传过程中创建进度条实时显示。
uploader.on( 'uploadProgress', function( file, percentage ) {
    var $li = $( '#'+file.id ),
        $percent = $li.find('.progress span');

    // 避免重复创建
    if ( !$percent.length ) {
        $percent = $('<p class="progress"><span></span></p>')
                .appendTo( $li )
                .find('span');
    }

    $percent.css( 'width', percentage * 100 + '%' );
});

// 文件上传成功，给item添加成功class, 用样式标记上传成功。
uploader.on( 'uploadSuccess', function(file,response) {
    if($("#picid").val()==''){
    		$("#picid").attr("value",(response.flag));
    	}else{
    		$("#picid").attr("value",($("#picid").val()+','+response.flag));
    	}
    	$( '#'+file.id ).find('p.state').text('已上传');

});

// 文件上传失败，显示上传出错。
uploader.on( 'uploadError', function( file ) {
    var $li = $( '#'+file.id ),
        $error = $li.find('div.error');

    // 避免重复创建
    if ( !$error.length ) {
        $error = $('<div class="error"></div>').appendTo( $li );
    }

    $error.text('上传失败');
});

// 完成上传完了，成功或者失败，先删除进度条。
uploader.on( 'uploadComplete', function( file ) {
    $( '#'+file.id ).find('.progress').remove();
});
   
  $('.skin-minimal input').iCheck({
     checkboxClass: 'icheckbox-blue',
     radioClass: 'iradio-blue',
     increaseArea: '20%'
  });
    
    $("#form-car-add").validate({
		rules:{
			carid:{
				required:true,
				iscarNum:true
			}
		},
      onkeyup:false,
      focusCleanup:true,
      success:"valid",
      submitHandler:function(form){

          $.ajax({

               type: 'post', 
               contentType:"application/json", 
               url: '/addCars',
               data:   JSON.stringify({
                      'carcode'     :$('#carcode').val(),
                      'carcolor'    :$('#carcolor').val(),
                      'buydate'     :$('#buydate').val(),
                      'enginenum'   :$('#enginenum').val(),
                      'framenum'    :$('#framenum').val(),
                      'cartype'     :$('#cartype').val(),
                      'carbrand'    :$('#carbrand').val(),
                      'carbrandtype':$('#carbrandtype').val(),
                      'picid'       :$('#picid').val(),
                      'isauto'      :$('#isauto').val(), 
                      'enginesize'  :$('#enginesize').val(), 
                      'seatnum'     :$('#seatnum').val(),
                      'facetype'    :$('#facetype').val(),
                      'totalmile'   :$('#totalmile').val(),  
                      'insurancetime':$('#insurancetime').val() ,
                      'yearcheck'   :$('#yearcheck').val(),
                      'maintaintime':$('#maintaintime').val(),   
                      'maintainmile':$('#maintainmile').val(),   
                      'phone'       :$('#phone').val(),
                      'carcity'     :$('#carcity').val(),
                      'dayprice'    :$('#dayprice').val(),   
                      'deptname'    :$('#deptname').val() ,                      
                      'carremark'   :$('#carremark').val()
                        }),
                success:function(data){ 
                    console.log('提交成功！');
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.$("#searchCar").click();
                    parent.layer.close(index);                   
                },
    			error:function(file){
    				removeFile(file);
    			}
            });
        }
    });
});
</script> 
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>